package edu.uta.cfl.GUI;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.Vector;
import java.util.regex.Pattern;

import javax.swing.BorderFactory;
import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JToolBar;
import javax.swing.JTree;
import javax.swing.ScrollPaneConstants;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.border.BevelBorder;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
import javax.swing.text.Element;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;

import net.coderazzi.filters.gui.AutoChoices;
import net.coderazzi.filters.gui.TableFilterHeader;
import net.coderazzi.filters.gui.TableFilterHeader.Position;
import edu.uta.cfl.console.CFLEngine;
import edu.uta.cfl.data.Combo;
import edu.uta.cfl.data.IterationResult;
import edu.uta.cfl.data.Parameter;
import edu.uta.cfl.data.SUT;
import edu.uta.cfl.data.SUT.SUTState;
import edu.uta.cfl.engine.DisplayInputFile;
import edu.uta.cfl.engine.SUTInfoReader;
//import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
//import com.ezware.oxbow.swingbits.table.filter.TableRowFilterSupport;

public class Gui {
	private static Gui instance;
	CFLEngine cflEngineObject = CFLEngine.getInstance();
	private JFrame frame;
	String testStrength = "0";
	String inputTestFile;
	String tempFile;
	String newTCFileLocation;
	String susComboFileLocation;
	String masterFileLocation; // added on 09/01/2014
	String sourceFileLocation;
	JTree tree;
	DefaultTreeModel treeModel;
	DefaultMutableTreeNode root;
	DefaultMutableTreeNode child; // added on 11/10/2014
	JPanel nsc_Panel;
	JPanel ntc_Panel;
	JTable nsc_JTable;
	JTable ntc_JTable;
	DefaultTableModel rtsTable;
	DefaultTableModel susTable;
	JTextArea masterFile_textArea;
	JTextArea sourceCodeFile_textArea;
	// RSyntaxTextArea sourceCode_textArea;
	JTextArea linenumber;
	String columnStr;
	public static SUT sut;
	public static int curCmbLen;
	public static int itr;
	boolean openedAlready = false;
	JTextField textField_IPM;
	JTextField textFieldPath_rts;
	JTextField textFieldFileName_rts;
	JTextField textField_projectName;
	JTextField textFieldPath_SC;
	JTextField textFieldFileName_SC;
	String rtc_Path;
	String rtc_fileName;
	String sc_Path;
	String sc_fileName;
	DefaultTableModel pTable = new DefaultTableModel();
	JTable parameterTable = new JTable(pTable);
	DefaultTableModel cTable = new DefaultTableModel();
	JTable constraintsTable = new JTable(cTable);
	DefaultTableModel testresultTable = new DefaultTableModel();
	JTable resultTable = new JTable(testresultTable);
	JButton initialBuildBtn = new JButton();
	JButton iterativeBuildBtn = new JButton();
	File selectedFile;
	Boolean validFile;
	String[] pnameArray;
	// DefaultMutableTreeNode parameters;
	StatusBar statusBar;
	JButton searchBtn = new JButton();
	TableFilterHeader susCombFilter = new TableFilterHeader();
	DefaultMutableTreeNode sourceCode = new DefaultMutableTreeNode(
			"Source Code");
	DefaultMutableTreeNode initialTestSet = new DefaultMutableTreeNode(
			"Initial Test Set");
	DefaultMutableTreeNode inputparametermodel = new DefaultMutableTreeNode(
			"Input Parameter Model");
	DefaultMutableTreeNode parameters = new DefaultMutableTreeNode("Parameters");
	DefaultMutableTreeNode constraints = new DefaultMutableTreeNode(
			"Constraints");
	DefaultMutableTreeNode masterFile = new DefaultMutableTreeNode(
			"Master File"); // added on 09/01/2014
	DefaultMutableTreeNode phase1 = new DefaultMutableTreeNode("Phase 1");
	JPanel susCombo_Panel; // added on 11/10/2014
	JTable susComponent_JTable;
	DefaultTableModel susComponentTable;
	String susComponentsFileLocation;
	JButton infoHelpBtn = new JButton();
	ArrayList<String> recommendedTestSet = new ArrayList<String>();
	ArrayList<String> suspiciousCombination = new ArrayList<String>();
	int susComboSize;
	public static int itrCount =0;

	JTable rts_JTable2;
	JTable rts_JTable3;
	JTable rts_JTable4;
	JTable rts_JTable5;
	JTable rts_JTable6;
	DefaultTableModel rtsTable2;
	DefaultTableModel rtsTable3;
	DefaultTableModel rtsTable4;
	DefaultTableModel rtsTable5;
	DefaultTableModel rtsTable6;
	JPanel rts_Panel2;
	JPanel rts_Panel3;
	JPanel rts_Panel4;
	JPanel rts_Panel5;
	JPanel rts_Panel6;

	JTable nsc_JTable2;
	JTable nsc_JTable3;
	JTable nsc_JTable4;
	JTable nsc_JTable5;
	JTable nsc_JTable6;
	DefaultTableModel nscTable2;
	DefaultTableModel nscTable3;
	DefaultTableModel nscTable4;
	DefaultTableModel nscTable5;
	DefaultTableModel nscTable6;
	JPanel nsc_Panel2;
	JPanel nsc_Panel3;
	JPanel nsc_Panel4;
	JPanel nsc_Panel5;
	JPanel nsc_Panel6;

	JTable susComponent_JTable2;
	JTable susComponent_JTable3;
	JTable susComponent_JTable4;
	JTable susComponent_JTable5;
	JTable susComponent_JTable6;
	DefaultTableModel susComponentTable2;
	DefaultTableModel susComponentTable3;
	DefaultTableModel susComponentTable4;
	DefaultTableModel susComponentTable5;
	DefaultTableModel susComponentTable6;
	JPanel susComponent_Panel2;
	JPanel susComponent_Panel3;
	JPanel susComponent_Panel4;
	JPanel susComponent_Panel5;
	JPanel susComponent_Panel6;


	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			@Override
			public void run() {
				try {
					UIManager.setLookAndFeel(UIManager
							.getSystemLookAndFeelClassName()); 
					Gui window = Gui.getInstance();
					window.frame.setVisible(true);

				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Singleton Pattern - only one instance of GUI should be created!
	 *
	 */
	public static Gui getInstance() {
		if (instance == null) {
			instance = new Gui();
		}
		return instance;

	}

	/**
	 * Create the application.
	 */
	public Gui() {
		initialize();
	}

	@SuppressWarnings("static-access")
	public void initialize() {
		// Frame
		frame = new JFrame("");// Creating Frame
		frame.setSize(1000, 600); // setBounds(int x co-ordinate, int y
									// co-ordinate, int height, int width)
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		JFrame.setDefaultLookAndFeelDecorated(true);
		frame.setLocationRelativeTo(null); // to position the window center on
											// the screen
		frame.setTitle("BEN");
		frame.setLayout(new BorderLayout());
		frame.setVisible(true);
		// Variables
		// Menu Bar Components
		JMenuBar menuBar = new JMenuBar();
		JMenu fileMenu = new JMenu(" File");
		JMenu helpMenu = new JMenu(" Help");
		JMenu editMenu = new JMenu(" Edit"); // added on 11/09/2014
		JMenu filterMenu = new JMenu(" Filter");
		JMenuItem fileOpen = new JMenuItem();
		JMenuItem fileOpen_MasterFile = new JMenuItem();
		JMenuItem fileExit = new JMenuItem();
		JMenuItem helpAbout = new JMenuItem();
		JMenuItem resetFilter = new JMenuItem("Reset Filter"); // added on
																// 11/09/2014
		final String aboutApplication = "Version 1.0";

		// ToolBar Components
		JToolBar toolBar = new JToolBar();
		JButton openFileBtn = new JButton();
		JButton newFileBtn = new JButton();
		// JButton infoHelpBtn = new JButton();

		// Right Panel components
		final JPanel sourceCodePanel = new JPanel();
		final JPanel initialTestSetPanel = new JPanel();

		// Create new Project Interface - 09/09/2014
		final JPanel createProjectPanel = new JPanel();
		JPanel projectName_Panel = new JPanel();
		JPanel ipmName_Panel = new JPanel();
		JPanel recommendedTest_Panel = new JPanel();
		// JPanel susCombo_Panel = new JPanel();

		// Componenets used in new Project Interface
		JLabel lblProjectName = new JLabel("Project Name:");

		JLabel lblinputName = new JLabel("IPM & Initial Test Set");

		textField_IPM = new JTextField();
		textField_IPM.setColumns(10);

		JButton btnOpen_inputFile = new JButton("Select Input File");
		JButton btnOpen_sourceFile = new JButton("Select Source code file"); // added
																				// on
																				// 09/24/2014
		JSeparator separator = new JSeparator();

		JSeparator separator_1 = new JSeparator();

		JLabel lblRecomTestSet = new JLabel("Recommended Test Set");

		textFieldPath_rts = new JTextField();
		textFieldPath_rts.setColumns(10);

		textFieldFileName_rts = new JTextField();
		textFieldFileName_rts.setColumns(10);

		textField_projectName = new JTextField();
		textField_projectName.setColumns(10);

		JLabel lblPath_rts = new JLabel("Path:");

		JLabel lblfileName_rts = new JLabel("File Name");

		JLabel lblSuspiciousCombinations = new JLabel("Suspicious Combinations");

		JLabel lblPath_SC = new JLabel("Path:");

		JLabel lblFileName_SC = new JLabel("File Name:");

		textFieldPath_SC = new JTextField();
		textFieldPath_SC.setColumns(10);

		textFieldFileName_SC = new JTextField();
		textFieldFileName_SC.setColumns(10);

		JButton btnPathBtn_rts = new JButton("Select Path");

		JButton btnPath_SC = new JButton("Select Path");

		final JPanel masterfilePanel = new JPanel(); // new panel added on
														// 09/01/2014
		masterfilePanel.setLayout(new BorderLayout());

		JLabel sourceCodeLabel = new JLabel("Source code");
		sourceCodePanel.setLayout(new BorderLayout());

		final JTabbedPane mainTab = new JTabbedPane();
		final JTabbedPane innerSpecificationTab = new JTabbedPane();
		mainTab.add("Source Code", sourceCodePanel);

		// mainTab.add("Input Parameter Model",innerSpecificationTab);
		// mainTab.add("Initial Test Set",initialTestSetPanel);
		// innerSpecificationTab.setBorder(BorderFactory.createCompoundBorder((BorderFactory.createRaisedBevelBorder()),
		// (BorderFactory.createLoweredBevelBorder())));
		innerSpecificationTab.setBorder(BorderFactory.createEmptyBorder(10, 10,
				10, 10));
		sourceCodePanel.add(sourceCodeLabel);

		initialTestSetPanel.setBorder(BorderFactory
				.createTitledBorder("Strength of the Test Set:     "));

		// Panel
		JPanel leftPanel = new JPanel();
		JPanel rightPanel = new JPanel();

		// Panels declarations for Constraints, Parameters and input test case
		// view
		final JPanel parameterPanel = new JPanel();
		parameterPanel.setLayout(new BorderLayout());
		final JPanel constraintsPanel = new JPanel();
		constraintsPanel.setLayout(new BorderLayout());
		initialTestSetPanel.setLayout(new BorderLayout());

		// Table logic

		parameterTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);

		pnameArray = new String[2]; // Declaring string array
		pnameArray[0] = "Parameter Name"; // initializing the array elements
											// individually
		pnameArray[1] = "Parameter Value";

		// TextArea declaration for Master file

		masterFile_textArea = new JTextArea();
		masterFile_textArea.setEditable(false);
		// masterFile_textArea.setText("Testing Text");
		masterFile_textArea.setLineWrap(true);
		masterFile_textArea.setWrapStyleWord(true);

		// TextArea declaration for source code file

		sourceCodeFile_textArea = new JTextArea();
		sourceCodeFile_textArea.setEditable(false);
		sourceCodeFile_textArea.setLineWrap(true);
		sourceCodeFile_textArea.setWrapStyleWord(true);

		linenumber = new JTextArea();
		linenumber.setBackground(Color.LIGHT_GRAY);
		linenumber.setEditable(false);

		sourceCodeFile_textArea.getDocument().addDocumentListener(
				new DocumentListener() {

					public String getText() {
						int linePosition = sourceCodeFile_textArea
								.getDocument().getLength();
						Element root = sourceCodeFile_textArea.getDocument()
								.getDefaultRootElement();
						String text = "1"
								+ System.getProperty("line.separator");
						for (int i = 2; i < root.getElementIndex(linePosition) + 2; i++) {
							text += i + System.getProperty("line.separator");
						}
						return text;
					}

					@Override
					public void insertUpdate(DocumentEvent e) {
						// TODO Auto-generated method stub
						linenumber.setText(getText());

					}

					@Override
					public void removeUpdate(DocumentEvent e) {
						// TODO Auto-generated method stub
						linenumber.setText(getText());

					}

					@Override
					public void changedUpdate(DocumentEvent e) {
						// TODO Auto-generated method stub
						linenumber.setText(getText());

					}
				});

		// ScrollPane declaration
		final JScrollPane parameterPane = new JScrollPane(parameterTable);
		parameterPane
				.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		parameterPane
				.setViewportBorder(new CompoundBorder(new CompoundBorder(null,
						new EtchedBorder(EtchedBorder.LOWERED, null, null)),
						null));
		parameterPane.setToolTipText("Parameters and Values");

		final JScrollPane constraintsPane = new JScrollPane(constraintsTable);
		constraintsPane
				.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		constraintsPane.setToolTipText("Constraints");

		JScrollPane initialTestPane = new JScrollPane(resultTable);
		initialTestPane
				.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		initialTestPane.setToolTipText("Initial Test Set");
		initialTestPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10,
				10));

		JScrollPane masterFilePane = new JScrollPane(masterFile_textArea);
		masterFilePane
				.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		masterFilePane.setToolTipText("Master file for the Project");

		// RTextArea implementation begins
		// sourceCode_textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
		// sourceCode_textArea.setCodeFoldingEnabled(true);
		// sourceCode_textArea.setAntiAliasingEnabled(true);
		// RTextScrollPane sourceCodeFilePane = new
		// RTextScrollPane(sourceCode_textArea);
		// RTextArea implementation ends

		// Commenting the existing code for the implementation of RTextArea
		JScrollPane sourceCodeFilePane = new JScrollPane();
		sourceCodeFilePane.getViewport().add(sourceCodeFile_textArea);
		sourceCodeFilePane.setRowHeaderView(linenumber);
		sourceCodeFilePane
				.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
		sourceCodeFilePane
				.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		sourceCodeFilePane.setToolTipText("Source code");

		parameterPanel.add(parameterPane);
		parameterPanel.setSize(200, 100);
		// parameterPanel.setBorder(BorderFactory.createTitledBorder("Parameters"));

		constraintsPanel.add(constraintsPane);
		constraintsPanel.setSize(200, 100);
		// constraintsPanel.setBorder(BorderFactory.createTitledBorder("Constraints"));

		innerSpecificationTab.add("Parameters", parameterPanel);
		innerSpecificationTab.add("Constraints", constraintsPanel);

		initialTestSetPanel.add(initialTestPane);

		sourceCodePanel.add(sourceCodeFilePane);
		masterfilePanel.add(masterFilePane);

		// Left panel components
		JLabel treeHeaderLabel = new JLabel();
		final String projectName_tree = "Project";
		root = new DefaultMutableTreeNode(projectName_tree);
		treeModel = new DefaultTreeModel(root);

		tree = new JTree(treeModel);

		// JSplitPane
		JSplitPane splitPane = new JSplitPane();
		splitPane.setDividerLocation(180);
		splitPane.setDividerSize(3);
		splitPane.setBorder(BorderFactory.createEmptyBorder(5, 10, 10, 10)); // Empty
																				// border
																				// for
																				// the
																				// split
																				// pane

		// Definition Logic

		// Menu items definition logic
		fileOpen.setText(" Create New Project ...");
		// fileOpen.setIcon(new
		// javax.swing.ImageIcon(getClass().getResource("cse/uta/edu/Images/open_project_16.png")));
		// fileOpen.setIcon(getClass().getResource("cse/uta/edu/Images/open_project_16.png"));
		fileOpen.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
				java.awt.event.KeyEvent.VK_O,
				java.awt.event.InputEvent.CTRL_MASK));
		fileOpen.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				int optionSelected = JOptionPane.YES_NO_OPTION;

				System.out.println("Testing:  " + openedAlready);
				if (openedAlready == true) {
					int optionChoosen = JOptionPane.showConfirmDialog(frame,
							"Do You Want to close the current Project?",
							"Confirm Close", optionSelected);
					if (optionChoosen == JOptionPane.NO_OPTION) {

						System.out
								.println("you have selected not to open a new file");

					}
					if (optionChoosen == JOptionPane.YES_OPTION) {

						startNewProject();
						statusBar.setMessage("Success...");
					}

				}

				else if (openedAlready == false) {
					System.out.println("Testing:  " + openedAlready);
					startNewProject();
					statusBar.setMessage("Success...");
				}

			}
		});
		fileOpen.setToolTipText("Click to open the Project");

		// New menu item added on 09/01/2014 - Open Existing Master File

		fileOpen_MasterFile.setText("Load Project ...");
		fileOpen_MasterFile.addActionListener(new ActionListener() {

			// **** 09/01/2014
			@Override
			public void actionPerformed(ActionEvent arg0) {
				int optionSelected = JOptionPane.YES_NO_OPTION;
				if (openedAlready == true) {
					int optionChoosen = JOptionPane.showConfirmDialog(frame,
							"Do You Want to close the current Project?",
							"Confirm Close", optionSelected);
					if (optionChoosen == JOptionPane.NO_OPTION) {

						System.out
								.println("you have selected not to open a new file");

					}
					if (optionChoosen == JOptionPane.YES_OPTION) {

						openMasterFile();
						statusBar.setMessage("Success...");
					}

				}

				else if (openedAlready == false) {
					openMasterFile();
				}

			}

		});
		// Jagan test code ends here - 09/01/2014
		fileExit.setText(" Exit");
		// fileExit.setIcon(new
		// javax.swing.ImageIcon(getClass().getResource("cse/uta/edu/Images/exit.png")));
		fileExit.setToolTipText("Exit the Application");
		fileExit.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				System.exit(0);

			}
		});

		helpAbout.setText(" About");
		helpAbout.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {

				JOptionPane.showMessageDialog(frame, aboutApplication);

			}
		});

		resetFilter.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				susCombFilter.resetFilter();

			}
		});
		// adding the menu items to menu
		fileMenu.add(fileOpen);
		fileMenu.add(fileOpen_MasterFile);
		fileMenu.addSeparator();
		fileMenu.add(fileExit);
		helpMenu.add(helpAbout);
		filterMenu.add(resetFilter);
		editMenu.add(filterMenu);
		fileMenu.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
		helpMenu.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
		editMenu.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
		// adding menu to menu bar
		menuBar.add(fileMenu);
		menuBar.add(editMenu);
		menuBar.add(helpMenu);

		// addding menubar to the window
		frame.setJMenuBar(menuBar);

		// ToolBar Components
		toolBar.setFloatable(false);

		openFileBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/cse/uta/edu/Images/open_project_24.png")));
		openFileBtn.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1,
				1, 4));
		newFileBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/cse/uta/edu/Images/new_project_24.png")));
		newFileBtn.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1,
				1, 4));
		infoHelpBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/cse/uta/edu/Images/help2.jpg")));
		infoHelpBtn.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1,
				1, 4));
		initialBuildBtn.setIcon(new javax.swing.ImageIcon(getClass()
				.getResource("/cse/uta/edu/Images/build_now_tb.png")));
		initialBuildBtn.setBorder(javax.swing.BorderFactory.createEmptyBorder(
				1, 1, 1, 4));
		initialBuildBtn.setEnabled(false);
		initialBuildBtn.setToolTipText("Initial iteration");

		iterativeBuildBtn.setIcon(new javax.swing.ImageIcon(getClass()
				.getResource("/cse/uta/edu/Images/build_project_24.png")));
		iterativeBuildBtn.setBorder(javax.swing.BorderFactory
				.createEmptyBorder(1, 1, 1, 4));
		iterativeBuildBtn.setEnabled(false);
		iterativeBuildBtn.setToolTipText("Next iteration");
		searchBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/cse/uta/edu/Images/search_16.png")));
		searchBtn.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1,
				1, 4)); // added on 11/06/2014
		searchBtn.setEnabled(false);
		searchBtn.setToolTipText("Search for a Suspicious Combination");

		toolBar.addSeparator();
		toolBar.add(newFileBtn);
		toolBar.add(openFileBtn);
		toolBar.addSeparator();
		toolBar.add(initialBuildBtn);
		toolBar.add(iterativeBuildBtn);
		toolBar.addSeparator();
		toolBar.add(searchBtn); // added on 11/06/2014
		toolBar.add(infoHelpBtn);

		// LeftPanel components definitions
		treeHeaderLabel.setText("System View");
		treeHeaderLabel.setHorizontalAlignment(SwingConstants.CENTER);
		treeHeaderLabel.setBorder(new CompoundBorder(BorderFactory
				.createBevelBorder(BevelBorder.RAISED), new EmptyBorder(5, 5,
				5, 5)));

		/*
		 * to be implemented later GroupLayout layout = new
		 * GroupLayout(leftPanel); leftPanel.setLayout(layout);
		 */

		// Tree to Tab reflection logic -- when a node is selected on Tree,
		// corresponding tab will become active
		tree.addTreeSelectionListener(new TreeSelectionListener() {

			@Override
			public void valueChanged(TreeSelectionEvent e) {
				DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) tree
						.getLastSelectedPathComponent();

				if (selectedNode.isLeaf()) {
					String nodeSelected = selectedNode.toString();
					if (nodeSelected == "Source Code") {
						mainTab.removeAll();
						mainTab.add("Source Code", sourceCodePanel);
						loadSourceCode(sourceFileLocation);
						statusBar.setMessage("Viewing Source Code");
					}
					if (nodeSelected == "Initial Test Set") {
						mainTab.removeAll();
						mainTab.add("Initial Test Set", initialTestSetPanel);
						statusBar.setMessage("Initial Test Set");
					}

					if (nodeSelected == "Parameters") {
						mainTab.removeAll();
						mainTab.add("Input Parameter Model",
								innerSpecificationTab);
						// innerSpecificationTab.setSelectedIndex(0);
						innerSpecificationTab.removeAll();
						innerSpecificationTab.add("Parameters", parameterPanel);
						statusBar.setMessage("Parameters");

					}

					if (nodeSelected == "Constraints") {
						mainTab.removeAll();
						mainTab.add("Input Parameter Model",
								innerSpecificationTab);
						// innerSpecificationTab.setSelectedIndex(1);
						innerSpecificationTab.removeAll();
						innerSpecificationTab.add("Constraints",
								constraintsPanel);
						statusBar.setMessage("Constraints");
					}
					if (nodeSelected == "Master File") {
						mainTab.removeAll();
						mainTab.add("Master File", masterfilePanel); // added on
																		// 09/01/2014
						loadMasterFile(masterFileLocation);
						statusBar.setMessage("Project Information File");
					}

				if(selectedNode.getParent().toString().equals("Iteration 1"))
				{
					if ((nodeSelected == "Suspicious Combination")) {
						mainTab.removeAll();
						mainTab.add("Suspicious Combinations", nsc_Panel);
						statusBar.setMessage("Suspicious Combination");

					}
					if (nodeSelected == "Recommended Test Case") {
						mainTab.removeAll();
						mainTab.add("Recommended Test Case", ntc_Panel);
						statusBar.setMessage("Recommended Test Case");
					}


					if (nodeSelected == "Suspicious Components") {
						mainTab.removeAll();
						mainTab.add("Suspicious Components", susCombo_Panel);
						statusBar.setMessage("Suspicious Components");
					}
				}

				if(selectedNode.getParent().toString().equals("Iteration 2"))
				{
					if ((nodeSelected == "Suspicious Combination")) {
						mainTab.removeAll();
						mainTab.add("Suspicious Combinations", nsc_Panel2);
						statusBar.setMessage("Suspicious Combination");

					}
					if (nodeSelected == "Recommended Test Case") {
						mainTab.removeAll();
						mainTab.add("Recommended Test Case", rts_Panel2);
						statusBar.setMessage("Recommended Test Case");
					}


					if (nodeSelected == "Suspicious Components") {
						mainTab.removeAll();
						mainTab.add("Suspicious Components", susComponent_Panel2);
						statusBar.setMessage("Suspicious Components");
					}
				}
				if(selectedNode.getParent().toString().equals("Iteration 3"))
				{
					if ((nodeSelected == "Suspicious Combination")) {
						mainTab.removeAll();
						mainTab.add("Suspicious Combinations", nsc_Panel3);
						statusBar.setMessage("Suspicious Combination");

					}
					if (nodeSelected == "Recommended Test Case") {
						mainTab.removeAll();
						mainTab.add("Recommended Test Case", rts_Panel3);
						statusBar.setMessage("Recommended Test Case");
					}


					if (nodeSelected == "Suspicious Components") {
						mainTab.removeAll();
						mainTab.add("Suspicious Components", susComponent_Panel3);
						statusBar.setMessage("Suspicious Components");
					}
				}
				if(selectedNode.getParent().toString().equals("Iteration 4"))
				{
					if ((nodeSelected == "Suspicious Combination")) {
						mainTab.removeAll();
						mainTab.add("Suspicious Combinations", nsc_Panel4);
						statusBar.setMessage("Suspicious Combination");

					}
					if (nodeSelected == "Recommended Test Case") {
						mainTab.removeAll();
						mainTab.add("Recommended Test Case", rts_Panel4);
						statusBar.setMessage("Recommended Test Case");
					}


					if (nodeSelected == "Suspicious Components") {
						mainTab.removeAll();
						mainTab.add("Suspicious Components", susComponent_Panel4);
						statusBar.setMessage("Suspicious Components");
					}
				}
				if(selectedNode.getParent().toString().equals("Iteration 5"))
				{
					if ((nodeSelected == "Suspicious Combination")) {
						mainTab.removeAll();
						mainTab.add("Suspicious Combinations", nsc_Panel5);
						statusBar.setMessage("Suspicious Combination");

					}
					if (nodeSelected == "Recommended Test Case") {
						mainTab.removeAll();
						mainTab.add("Recommended Test Case", rts_Panel5);
						statusBar.setMessage("Recommended Test Case");
					}


					if (nodeSelected == "Suspicious Components") {
						mainTab.removeAll();
						mainTab.add("Suspicious Components", susComponent_Panel5);
						statusBar.setMessage("Suspicious Components");
					}
				}
				if(selectedNode.getParent().toString().equals("Iteration 6"))
				{
					if ((nodeSelected == "Suspicious Combination")) {
						mainTab.removeAll();
						mainTab.add("Suspicious Combinations", nsc_Panel6);
						statusBar.setMessage("Suspicious Combination");

					}
					if (nodeSelected == "Recommended Test Case") {
						mainTab.removeAll();
						mainTab.add("Recommended Test Case", rts_Panel6);
						statusBar.setMessage("Recommended Test Case");
					}


					if (nodeSelected == "Suspicious Components") {
						mainTab.removeAll();
						mainTab.add("Suspicious Components", susComponent_Panel6);
						statusBar.setMessage("Suspicious Components");
					}
				}


				} // end of leaf!

			}
		});

		// Introducing StatusBar
		statusBar = new StatusBar();
		JPanel statusPanel = new JPanel();
		statusPanel.setLayout(new BorderLayout());
		statusPanel.add(statusBar, BorderLayout.WEST); // aligning the status
														// Message to the left
														// side of the screen
		statusPanel.setBorder(BorderFactory.createCompoundBorder(
				BorderFactory.createRaisedBevelBorder(),
				BorderFactory.createLoweredBevelBorder()));

		// aligning the elements on screen starts

		// leftPanel.add(treeHeaderLabel,BorderLayout.NORTH);
		leftPanel.setLayout(new BorderLayout());
		leftPanel.add(tree, BorderLayout.CENTER);

		splitPane.setLeftComponent(leftPanel);
		splitPane.setRightComponent(mainTab);

		frame.add(toolBar, BorderLayout.NORTH);
		frame.add(splitPane, BorderLayout.CENTER);
		frame.add(statusPanel, BorderLayout.SOUTH);
		// aligning the elements on screen ends

		// GUI Part ends

		// new interface logic starts
		newFileBtn.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent arg0) {

				int optionSelected = JOptionPane.YES_NO_OPTION;
				if (openedAlready == true) {
					int optionChoosen = JOptionPane.showConfirmDialog(frame,
							"Do You Want to close the current Project?",
							"Confirm Close", optionSelected);
					if (optionChoosen == JOptionPane.NO_OPTION) {

						System.out
								.println("you have selected not to open a new file");

					}
					if (optionChoosen == JOptionPane.YES_OPTION) {

						startNewProject();
						statusBar.setMessage("Success...");
					}

				}

				else if (openedAlready == false) {
					startNewProject();
				}
			}
		});

		// new interface logic ends

		// logic testing starts
		infoHelpBtn.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				//firstIteration();

			}
		});
		// logic testing ends

		// functionality part begins
		openFileBtn.addActionListener(new ActionListener() {
			@SuppressWarnings("serial")
			@Override
			public void actionPerformed(ActionEvent e) {

				JFileChooser f1 = new JFileChooser();

				ArrayList<String> parameters_name = new ArrayList<String>();
				ArrayList<String> parameters_value = new ArrayList<String>();
				ArrayList<String> testResult_value = new ArrayList<String>();
				ArrayList<String> testResults = new ArrayList<String>();
				ArrayList<Parameter> parameters_initialForm = new ArrayList<Parameter>();
				int optionSelected = JOptionPane.YES_NO_OPTION;
				if (openedAlready == true) {
					int optionChoosen = JOptionPane.showConfirmDialog(frame,
							"Do You Want to close the current Project?",
							"Confirm Close", optionSelected);
					if (optionChoosen == JOptionPane.NO_OPTION) {

						System.out
								.println("you have selected not to open a new file");

					}
					if (optionChoosen == JOptionPane.YES_OPTION) {

						openMasterFile();
						statusBar.setMessage("Success...");
					}

				}

				else if (openedAlready == false) {
					openMasterFile();
				}
			} // end of if loop openedAlready
		});

		initialBuildBtn.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				statusBar.setMessage("Running Iteration 1"); // updating the status bar
				// Call for first iteration
				initialLoad();
				int count = 1;
				modifyTree(count);


			}
		});

		iterativeBuildBtn.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent arg0) {
				toContinueIteration();
			}
		});

	} // end of initialize() method

	@SuppressWarnings("static-access")
	protected void toContinueIteration() {
		int optionSelected = JOptionPane.YES_NO_OPTION;

		int optionChoosen = JOptionPane.showConfirmDialog(frame,
				"Do You Want to continue with the next iteration?",
				"Confirm Close", optionSelected);

		if (optionChoosen == JOptionPane.NO_OPTION) {
			System.out.println("you have selected not to Continue with the next iteration");
		}

		if (optionChoosen == JOptionPane.YES_OPTION) {
		System.out.println("you have selected to continue with the iteration");

		Boolean resultsUpdated = isResultUpdated(itrCount);

		if(resultsUpdated == true)
		{



			ArrayList<Integer> resultsFromUser = updatedTestResult(itrCount);
			cflEngineObject.processAddTest(resultsFromUser);

			SUT localSUT_Continue = cflEngineObject.getSut();
			int curCmbLen = cflEngineObject.curCmbLen;
			checkSUTStatus(localSUT_Continue);
			if(localSUT_Continue.getStatus() == SUTState.continuing )
			{
				itrCount++;
				modifyTree(itrCount);
				updateGUI(localSUT_Continue.getIterationObject().get(itrCount-1),itrCount,localSUT_Continue,curCmbLen);
			}

		}

		else if(resultsUpdated == false)
		{
			JOptionPane.showMessageDialog(frame, "Please update the result section","Inane error",JOptionPane.ERROR_MESSAGE);
		}

		}

	}

	protected ArrayList<Integer> updatedTestResult(int iterationCount) {

		ArrayList<Integer> resultFromUser = new ArrayList<Integer>();
		if(iterationCount==1)
		{
			resultFromUser = new GetResultsFromUser(ntc_JTable).getResults();

		}
		if(iterationCount==2)
		{
			resultFromUser = new GetResultsFromUser(rts_JTable2).getResults();

		}
		if(iterationCount==3)
		{
			resultFromUser = new GetResultsFromUser(rts_JTable3).getResults();

		}
		if(iterationCount==4)
		{
			resultFromUser = new GetResultsFromUser(rts_JTable4).getResults();

		}
		if(iterationCount==5)
		{
			resultFromUser = new GetResultsFromUser(rts_JTable5).getResults();

		}
		if(iterationCount==6)
		{
			resultFromUser = new GetResultsFromUser(rts_JTable6).getResults();

		}
		return resultFromUser;



	}

	protected boolean isResultUpdated(int iterationCount) {
		ValidateTableResult checkTableResults = new ValidateTableResult();
		boolean resultUpdated = false;

		if(iterationCount==1)
		{
			resultUpdated = checkTableResults.isNotEmpty(ntc_JTable);

		}
		if(iterationCount==2)
		{
			resultUpdated = checkTableResults.isNotEmpty(rts_JTable2);

		}
		if(iterationCount==3)
		{
			resultUpdated = checkTableResults.isNotEmpty(rts_JTable3);

		}
		if(iterationCount==4)
		{
			resultUpdated = checkTableResults.isNotEmpty(rts_JTable4);

		}
		if(iterationCount==5)
		{
			resultUpdated = checkTableResults.isNotEmpty(rts_JTable5);

		}
		if(iterationCount==6)
		{
			resultUpdated = checkTableResults.isNotEmpty(rts_JTable6);

		}


		return resultUpdated;
	}

	protected void loadSusCombo(IterationResult itr, DefaultTableModel susComponentTable,JTable susComponent_JTable, SUT localSUT) {

		susComboHeader(susComponentTable);
		susComboRow(itr,susComponentTable,localSUT);
		new TableDecorator(susComponent_JTable).updateTableUI();
		susComponent_JTable.setEnabled(false);
		susComponent_JTable.getTableHeader().setReorderingAllowed(false);

	}

	protected void startNewProject() {
		NewProject_Dialog window = new NewProject_Dialog();
		window.setVisible(true);
		Boolean status = false;
		status = window.getFileReadSuccess();

		if (status == true) {

			String projectName_tree = window.getProjectName();
			String inputFileLocation = window.getInputFileLocation();
			String rts_Path = window.getRts_PathName();
			String sc_Path = window.getSc_PathName();
			String rts_FileName = window.getRts_FileName();
			String sc_FileName = window.getSc_FileName();
			String masterFile_Directory = window.getDirName(); // IPM's directory to create the master file
			sourceFileLocation = window.getSourceCodeFileLocation();
			newTCFileLocation = rts_Path + File.separator + rts_FileName
					+ ".txt";
			susComboFileLocation = sc_Path + File.separator + sc_FileName
					+ ".txt";
			masterFileLocation = masterFile_Directory + File.separator
					+ "masterFile.txt";

			updateTree();
			updateTreeRoot(projectName_tree);
			createMasterFile(masterFileLocation);
			loadInputFile(inputFileLocation, rts_Path, sc_Path, rts_FileName,
					sc_FileName);
			updateMasterFile(masterFileLocation, inputFileLocation,
					newTCFileLocation, susComboFileLocation, projectName_tree,
					sourceFileLocation);
		}
	}



	private void updateTree() {
		// TODO Auto-generated method stub

		root.add(masterFile); // added on 09/01/2014
		root.add(sourceCode);
		root.add(inputparametermodel);
		root.add(initialTestSet);
		inputparametermodel.add(parameters);
		inputparametermodel.add(constraints);
		tree.getSelectionModel().setSelectionMode(
				TreeSelectionModel.SINGLE_TREE_SELECTION);
		tree.setShowsRootHandles(true);

	}

	@SuppressWarnings("serial")
	protected void openMasterFile() {

		ArrayList<String> parameters_name = new ArrayList<String>();
		ArrayList<String> parameters_value = new ArrayList<String>();
		ArrayList<String> testResult_value = new ArrayList<String>();
		ArrayList<String> testResults = new ArrayList<String>();
		ArrayList<Parameter> parameters_initialForm = new ArrayList<Parameter>();

		selectFile();
		ValidateInputFile validateObject = new ValidateInputFile();
		validFile = validateObject.ValidFile(selectedFile);

		if (validFile == false) {
			JOptionPane.showMessageDialog(null, "Invalid File", "Error",
					JOptionPane.ERROR_MESSAGE);
			statusBar.setMessage("Invalid File");
		}

		if (validFile == true) {

			statusBar
					.setMessage("Valid Master File.... Reading the information....");
			inputTestFile = validateObject.getIpmfile_Location();
			masterFileLocation = selectedFile.getPath();
			sourceFileLocation = validateObject.getSourceCodeLocation();

			System.out.println("Master File Location:" + masterFileLocation);
			// createMasterFile(masterFileLocation);
			susComboFileLocation = validateObject.getSc_Location();
			newTCFileLocation = validateObject.getRts_Location();
			String projectName = validateObject.getProject_Name();
			/*
			 * newTCFileLocation = f1.getCurrentDirectory().toString() +
			 * "//newTC.txt"; susComboFileLocation = f1.getCurrentDirectory()
			 * .toString() + "//newSusCombo.txt"; masterFileLocation =
			 * f1.getCurrentDirectory() .toString() + "//masterFile.txt";
			 * createMasterFile(masterFileLocation);
			 */
			sut = new SUT();
			sut = (new SUTInfoReader(inputTestFile)).getSUT();
			// updateMasterFile(masterFileLocation, inputTestFile);
			// Obtaining information from SUTInfoReader.java file
			// starts
			// new testing starts
/*
			curCmbLen = sut.getStrength();
			SUTManager
					.approach(sut, sut.getStrength(), Constants.APPROACH_LOAD);

			// approachState = Constants.APPROACH_ADD;
			ArrayList<int[]> tcList = new ArrayList<int[]>();

			if (sut.getStatus() == SUTState.expansion) {
				sut.setStatus(SUTState.expansion);
				int len = curCmbLen;
				while ((sut.getStatus() == SUTState.expansion)
						&& len < Constants.maxIndStr - 1)
					SUTManager.expandCmb(sut, len++);

				curCmbLen = len;

				if (len < Constants.maxIndStr - 1)
					tcList = SUTManager.generateNewTC(sut, curCmbLen);
				else
					sut.setStatus(SUTState.notFound);

				itr = 0;
			} else
				tcList = SUTManager.generateNewTC(sut, sut.getStrength());
			System.out.println("*******" + sut.getStatus().toString());
			if (sut.getStatus() == SUTState.continuing) {
				printTCList(tcList, sut.getParameters());
				printSUT(sut, curCmbLen);
			} else {
				// (new SUTInfoWriter(outSpc)).printSUT(sut, curCmbLen);
				// (new SUTInfoWriter(
				// outSpc.substring(0, outSpc.lastIndexOf("\\") + 1)
				// + "cmp.txt")).printSuspiciousness(sut, curCmbLen);
			}

			// printOutput(sut.getStatus(), outTestset);
*/
			// new testing ends

			updateTree();
			updateTreeRoot(projectName);
			// Parameters
			parameters_initialForm = sut.getParameters();
			for (Parameter p : parameters_initialForm) {
				parameters_name.add(p.getName());
				parameters_value.add(p.getValues().toString());
			}

			// Testing starts for printing the initial test result
			// column name
			String output = "";
			for (Parameter prm : parameters_initialForm)
				output += prm.getName() + ", ";
			String testSet_columnHeader = "[" + output + "]";
			System.out.println("Testing now ..." + output);
			// Testing ends
			// Updating the Parameters table

			pTable.setColumnCount(0);
			pTable.setRowCount(0);

			for (int col = 0; col < pnameArray.length; col++) {
				pTable.addColumn(pnameArray[col]);
			}

			for (int row = 0; row < parameters_name.size(); row++) {
				pTable.insertRow(row, new Object[] { parameters_name.get(row),
						parameters_value.get(row) });
			}

			// logic to update the UI of parameter table starts
			new TableDecorator(parameterTable).updateTableUI();
			parameterTable.setEnabled(false); // non - editable parameter table

			// logic to update the UI of parameter table ends.
			// Updating the Constraints Table
			String[] columnName = { "Constraints" };
			cTable.setColumnCount(0);
			cTable.setRowCount(0);

			for (int col = 0; col < columnName.length; col++) {
				cTable.addColumn(columnName[col]);
			}

			for (int r = 0; r < sut.getConstraints().size(); r++) {
				cTable.insertRow(r,
						new Object[] { sut.getConstraints().get(r) });
			}

			constraintsTable.setEnabled(false); // non - editable constraints
												// table

			// initial test set with results
			testresultTable.setColumnCount(0);
			testresultTable.setRowCount(0);

			// Initial Test Result column calculation

			ArrayList<String> testDataColumnName = new ArrayList<String>();
			int count_new = 0;
			testDataColumnName.add("Row Index");
			for (Parameter prm : parameters_initialForm)

			{
				// System.out.println("hehehehehe  "+count_new+"  the value is  "+prm.getName());
				testDataColumnName.add(prm.getName());
				count_new++;
			}

			testDataColumnName.add("Result");

			// calculating test data results
			int testResultSize = sut.getTs().getResult().size();

			for (int count = 0; count < testResultSize; count++) {

				testResult_value.add(sut.getTs().getResult().get(count)
						.toString());
			}

			for (int count = 0; count < testResult_value.size(); count++) {
				String pass = "Pass";
				String fail = "fail";
				System.out.println("Count :" + count + "   Value :"
						+ testResult_value.get(count).toString());

				if (testResult_value.get(count).toString()
						.equalsIgnoreCase("1")) {
					testResults.add(count, pass);
					System.out.println("testing: pass loop  "
							+ testResults.size());
				} else if (testResult_value.get(count).toString()
						.equalsIgnoreCase("0")) {
					testResults.add(count, fail);
					System.out.println("testing:fail loop  "
							+ testResults.size());
				}
			}

			System.out.println("testing:   " + testResults.size());
			// updating the table
			for (int col = 0; col < testDataColumnName.size(); col++) {
				testresultTable.addColumn(testDataColumnName.get(col));
			}

			ArrayList<String> testData = new ArrayList<String>();
			int testArray = sut.getTs().getMatrix().size();
			System.out.println("Jagan testing ..." + testArray + "\n"
					+ Arrays.toString(sut.getTs().getMatrix().get(1)));
			String a = Arrays.toString(sut.getTs().getMatrix().get(1));
			String arrayString[] = new String[testArray];
			System.out.println("Jagan testing .... round 2" + a);

			for (int i = 0; i < testArray; i++) {
				arrayString[i] = Arrays
						.toString(sut.getTs().getMatrix().get(i));
			}
			int rowCount = 0;

			for (String k : arrayString) {
				k = k.replace("[", "");
				k = k.replace("]", "");
				// int count_string =1;
				Pattern paramPattern = Pattern.compile(",");
				String[] tokens = paramPattern.split(k);
				ArrayList<String> jaganTest = new ArrayList<String>();
				jaganTest.add(Integer.toString(rowCount+1));
				for (int i = 0; i < tokens.length; i++) {
					jaganTest.add(tokens[i]);
					//System.out.println("Printing data from ...."
							//+ jaganTest.size() + "\n");

				}

				jaganTest.add(testResults.get(rowCount)); // adding
															// results
															// to
															// the
															// List

				/*
				 * System.out.println("\n==> Iterator Example...new") ;
				 * Iterator<String> testIterator1 = jaganTest.iterator(); while
				 * (testIterator1.hasNext()) {
				 * System.out.println(testIterator1.next()); }
				 */
				// System.out.println("testing"+tokens.length);

				Vector<Object> row1 = new Vector<Object>();
				int count = 1;
				// logic to update the vector object
				// for(int i=0;i<tokens.length;i++)
				for (int i = 0; i < jaganTest.size(); i++) {
					// row1.add(tokens[i]);
					row1.add(jaganTest.get(i));
					System.out.println("Row #: " + count);
					// System.out.println(tokens[i]);
					count++;
				}

				testresultTable.addRow(row1);
				// added on 09/12/2014 - to
				new TableDecorator(resultTable).updateTableUI();
				resultTable.getTableHeader().setReorderingAllowed(false);
				resultTable.setEnabled(false); 
				parameterTable.getTableHeader().setReorderingAllowed(false);
				/*
				 * testresultTable.prepareRenderer(TableCellRenderer renderer,
				 * int row, int column){ Component returnComp =
				 * super.prepareRenderer(renderer, row, column); Color
				 * alternateColor = new Color(252,242,206); Color whiteColor =
				 * Color.WHITE; if (!returnComp.getBackground().equals
				 * (getSelectionBackground())){ Color bg = (row % 2 == 0 ?
				 * alternateColor : whiteColor); returnComp .setBackground(bg);
				 * bg = null; } return returnComp; };
				 */
				// System.out.println("Jagan Testing...."+rowCount+"..."+k);
				// rowCount++;
				rowCount++;
				System.out.println("Here we are ....\t" + jaganTest.size()
						+ "\n" + rowCount);
			}

			for (int row = 0; row < sut.getTs().getMatrix().size(); row++) {
				// testresultTable.insertRow(row, new
				// Object[]{Arrays.toString(sut.getTs().getMatrix().get(row)),testResults.get(row)});
			} // Obtaining information from SUTInfoReader.java ends
			statusBar.setMessage(projectName + ": Information");
			initialBuildBtn.setEnabled(true);
			openedAlready = true;
			tree.setSelectionPath(new TreePath(parameters));
		}

	}

	private void printSUT(SUT sut, int curCmbLen) {

		for (Combo cmb : sut.getSuspiciousCombos(curCmbLen)) {

			String susCombination = cmb.getRank() + ","
					+ printPN_PV(cmb, sut.getParameters())
					+ String.format("%f", cmb.getRankValue()) + ","
					+ String.format("%f", cmb.getEnvRankValue());
			// System.out.println("Testing....."+susCombination);
			suspiciousCombination.add(susCombination);
		}

		// if ( sut.getStatus() != SUT.SUTState.continuing){
		// if (sut.getSuspiciousCombos(len - 1).size() > 0) {
		/*
		 * int cnt = 0; for (int i = 1; i < len; cnt +=
		 * sut.getSuspiciousCombos(i++).size()) ; if (cnt > 0) {
		 * out.println("\n\nDerived combos:");
		 *
		 * for (int i = 1; i < len; i++) { if (sut.getSuspiciousCombos(i).size()
		 * > 0) {
		 *
		 * out.println("\n" + i + "-way suspicious combos");
		 * out.println("\nRank , \tCombo ,\tMin SoC  "); for (Combo cmb :
		 * sut.getSuspiciousCombos(i)) { out.format("%d , ", cmb.getRank());
		 * out.print(ComboManager.ToString(cmb, sut.getParameters()));
		 * out.format( " , %f \n", ComboManager.minSpcSubCmb(cmb,
		 * sut.getSuspiciousCombos(i + 1))); // ComboManager.maxRankSubCmb(cmb,
		 * // sut.getSuspiciousCombos(i+1))); // ComboManager.maxSpcSubCmb(cmb,
		 * // sut.getSuspiciousCombos(i+1)), // ComboManager.avgSpcSubCmb(cmb,
		 * // sut.getSuspiciousCombos(i+1))); } } } }
		 */}

	// out.close();

	private String printPN_PV(Combo cmb, ArrayList<Parameter> parameters) {

		String output = "";
		String formattedOutput = "";
		for (edu.uta.cfl.data.Component cmp1 : cmb.getComponent()) {
			Parameter prm = parameters.get(parameters.indexOf(cmp1
					.getParameter()));
			output += "Parameter 1: " + prm.getName() + "\nParameter Value:  "
					+ prm.getValues().get(cmp1.getValue()) + "\n";
			formattedOutput += prm.getName() + ","
					+ prm.getValues().get(cmp1.getValue()) + ",";
		}

		return formattedOutput;
	}

	private void printTCList(ArrayList<int[]> tcList,
			ArrayList<Parameter> parameters) {
		System.out.println("Recommended Test Set - HEADER infromation\n");
		// printing header information
		for (Parameter prm : parameters) {
			System.out.println(prm.getName());
		}
		// printing row information
		int stater = 0;
		int i;
		String test;
		for (int[] tc : tcList) {
			test = "" + stater++ + " , ";
			for (i = 0; i < tc.length - 1; i++)
				test += parameters.get(i).getValues().get(tc[i]) + " , ";

			test += tc[tc.length - 1];
			recommendedTestSet.add(test);
			System.out.println(test + "\n" + recommendedTestSet.size());
		}
		Pattern values = Pattern.compile(",");
		String[] value;
		for (int a = 0; a < recommendedTestSet.size(); a++) {
			String[] tokens = values.split(recommendedTestSet.get(a));
			System.out.println(tokens.toString());
		}
	}

	protected void selectFile() {
		JFileChooser fileChooser = new JFileChooser();
		FileNameExtensionFilter textFilter = new FileNameExtensionFilter(
				"Text Files", "txt");
		fileChooser.setFileFilter(textFilter);
		fileChooser.addChoosableFileFilter(new TextFileFilter());
		int returnValue = fileChooser.showOpenDialog(null);
		if (returnValue == JFileChooser.APPROVE_OPTION) {
			selectedFile = fileChooser.getSelectedFile();
		}

	}

	protected void updateTreeRoot(String projectName) {
		// method to update the project name in the JTree
		DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
		DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
		root.setUserObject(projectName);
		model.nodeChanged(root);

	}

	// refactoring - moving the read file logic to this function for code
	// re-usability
	protected void loadInputFile(String inputFileLocation, String rts_Path,
			String sc_Path, String rts_FileName, String sc_FileName) {
		inputTestFile = inputFileLocation;
		
		DisplayInputFile getIpFileInfo = new DisplayInputFile(inputFileLocation);
		getIpFileInfo.readInputFile();
		
		ArrayList<String> parameters_name = getIpFileInfo.getParameters_name();
		ArrayList<String> parameters_value = getIpFileInfo.getParameters_value();
		ArrayList<String> constraints = getIpFileInfo.getConstraintsValue();
		
		ArrayList<String> testDataColumnName = getIpFileInfo.getTestSetColumnName();
		ArrayList<String> initialTestSet = getIpFileInfo.getInitialTestSet();
		

		final String[] pnameArray = new String[2]; // Declaring string array
		pnameArray[0] = "Parameter Name"; // initializing the array elements individually											
		pnameArray[1] = "Parameter Value";

		pTable.setColumnCount(0);
		pTable.setRowCount(0);

		for (int col = 0; col < pnameArray.length; col++) {
			pTable.addColumn(pnameArray[col]);
		}

		for (int row = 0; row < parameters_name.size(); row++) {
			pTable.insertRow(row, new Object[] { parameters_name.get(row),
					parameters_value.get(row) });
		}
		new TableDecorator(parameterTable).updateTableUI(); // logic to update the UI of parameter table starts
		parameterTable.setEnabled(false);
		
	// Updating the Constraints Table
		String[] columnName = { "Constraints" };
		cTable.setColumnCount(0);
		cTable.setRowCount(0);

		for (int col = 0; col < columnName.length; col++) {
			cTable.addColumn(columnName[col]);
		}

		for (int r = 0; r < constraints.size(); r++) {
			cTable.insertRow(r, new Object[] {constraints.get(r) });
		}
		constraintsTable.setEnabled(false);
		
		// initial test set with results
		testresultTable.setColumnCount(0);
		testresultTable.setRowCount(0);

		// Initial Test Result column calculation

		//ArrayList<String> testDataColumnName = new ArrayList<String>();
		ArrayList<String> testResult_value = new ArrayList<String>();
		ArrayList<String> testResults = new ArrayList<String>();
		

		
		SUT sut= new SUTInfoReader(inputFileLocation).getSUT();
		// calculating test data results
		int testResultSize = sut.getTs().getResult().size();

		for (int count = 0; count < testResultSize; count++) {

			testResult_value.add(sut.getTs().getResult().get(count)
					.toString());
		}

		for (int count = 0; count < testResult_value.size(); count++) {
			String pass = "Pass";
			String fail = "fail";
			System.out.println("Count :" + count + "   Value :"
					+ testResult_value.get(count).toString());

			if (testResult_value.get(count).toString()
					.equalsIgnoreCase("1")) {
				testResults.add(count, pass);
				System.out.println("testing: pass loop  "
						+ testResults.size());
			} else if (testResult_value.get(count).toString()
					.equalsIgnoreCase("0")) {
				testResults.add(count, fail);
				System.out.println("testing:fail loop  "
						+ testResults.size());
			}
		}

		System.out.println("testing:   " + testResults.size());
		// updating the table
		for (int col = 0; col < testDataColumnName.size(); col++) {
			testresultTable.addColumn(testDataColumnName.get(col));
		}

		ArrayList<String> testData = new ArrayList<String>();
		int testArray = sut.getTs().getMatrix().size();
		String arrayString[] = new String[testArray];
		
		for (int i = 0; i < testArray; i++) {
			arrayString[i] = Arrays
					.toString(sut.getTs().getMatrix().get(i));
		}
		int rowCount = 0;
		
		for (String k : arrayString) {
			k = k.replace("[", "");
			k = k.replace("]", "");
			// int count_string =1;
			Pattern paramPattern = Pattern.compile(",");
			String[] tokens = paramPattern.split(k);
			ArrayList<String> initialTestSet1 = new ArrayList<String>();
			initialTestSet1.add(Integer.toString(rowCount+1));
			for (int i = 0; i < tokens.length; i++) {
				initialTestSet1.add(tokens[i]);
				
			}
			initialTestSet1.add(testResults.get(rowCount)); 
			Vector<Object> row1 = new Vector<Object>();
			
			for (int i = 0; i < initialTestSet1.size(); i++) {
				row1.add(initialTestSet1.get(i));
				
			}
			testresultTable.addRow(row1);
			rowCount++;

		}
		new TableDecorator(resultTable).updateTableUI();
		resultTable.setEnabled(false); 
		//statusBar.setMessage(projectName + ": Information");
		initialBuildBtn.setEnabled(true);
		openedAlready = true;
		parameterTable.getTableHeader().setReorderingAllowed(false);
		resultTable.getTableHeader().setReorderingAllowed(false);
		tree.setSelectionPath(new TreePath(parameters));

	}

	// refactoring - moving the read fileJTextArea logic to this function for
	// code
	// re-usability ends
	protected void updateMasterFile_results(int count,
			String masterFileLocation, String newTCFileLocation,
			String susComboFileLocation) {
		// Updating the master with iteration results

		try {
			File file = new File(masterFileLocation);

			FileWriter fWriter = new FileWriter(file.getAbsoluteFile(), true);
			BufferedWriter bufferedWriter = new BufferedWriter(fWriter);
			bufferedWriter.append("\n" + "Recommended Test Set : " + "\n"
					+ "   File Location:  " + newTCFileLocation + "\n" + "\n"
					+ "Suspicious Combinations: " + "\n" + "   File Location: "
					+ susComboFileLocation + "\n");
			bufferedWriter.close();
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	protected void updateMasterFile(String masterFileLocation,
			String fileInformation, String rts_fileInfo, String sc_fileInfo,
			String projectName, String sourceFileLocation) {
		// Updating the Master File with Specification file information

		try {
			File file = new File(masterFileLocation);

			FileWriter fWriter = new FileWriter(file.getAbsoluteFile(), true);
			BufferedWriter bufferedWriter = new BufferedWriter(fWriter);
			bufferedWriter.append("\n" + "Project Name--    " + projectName
					+ "\n");
			bufferedWriter.append("\n" + "Source File Location--   "
					+ sourceFileLocation + "\n");
			bufferedWriter.append("\n" + "IPM + Initial Test Result--   "
					+ fileInformation + "\n");
			bufferedWriter.append("\n" + "Recommended Test Set--  "
					+ rts_fileInfo + "\n");
			bufferedWriter.append("\n" + "Suspicious Combinations--  "
					+ sc_fileInfo + "\n");
			bufferedWriter.close();
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	protected void createMasterFile(String fileLocation) {
		// creating MasterFile with default information
		try {
			File file = new File(fileLocation);
			if (!file.exists()) {
				System.out.println("No File Found... creating new file");
				file.createNewFile();
			}

			System.out.println("testing:" + fileLocation);
			String timestamp = new java.text.SimpleDateFormat(
					"MM/dd/yyyy h:mm:ss a").format(new Date());
			FileWriter fWriter = new FileWriter(file.getAbsoluteFile());
			BufferedWriter bufferedWriter = new BufferedWriter(fWriter);
			bufferedWriter.write("# BEN Master File : " + timestamp + "\n");
			bufferedWriter.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	protected void loadMasterFile(String masterFile) {
		// to load contents in masterFile_textArea
		try {
			String textLine;
			FileReader fr = new FileReader(masterFile);
			BufferedReader reader = new BufferedReader(fr);
			masterFile_textArea.setText(null);
			while ((textLine = reader.readLine()) != null) {
				masterFile_textArea.append(textLine + "\n");
			}
		} catch (IOException ioe) {
			System.err.println(ioe);
			System.exit(1);
		}

	}

	protected void loadSourceCode(String sourceFileLocation) {
		// to load contents in Source code file area
		try {

			String textLine;
			FileReader fr = new FileReader(sourceFileLocation);
			BufferedReader reader = new BufferedReader(fr);
			sourceCodeFile_textArea.setText(null);
			while ((textLine = reader.readLine()) != null) {
				// sourceCodeFile_textArea.setText(textLine+"\n");
				sourceCodeFile_textArea.append(textLine + "\n");
			}

		} catch (IOException ioe) {
			System.err.println(ioe);
			System.exit(1);
		}
	}

	protected void displayInfo() {
		String msg = sut.getInitialDisplayMessage();
		// JOptionPane.showMessageDialog(frame, msg);
		System.out.println(msg);

	}



	protected void modifyTree(int count) {

		child = new DefaultMutableTreeNode("Iteration " + count);
		DefaultMutableTreeNode susCombo = new DefaultMutableTreeNode(
				"Suspicious Combination");
		DefaultMutableTreeNode recommendedTestCases = new DefaultMutableTreeNode(
				"Recommended Test Case");
		DefaultMutableTreeNode susComponents = new DefaultMutableTreeNode(
				"Suspicious Components");
		treeModel.insertNodeInto(child, root, root.getChildCount());
		treeModel.insertNodeInto(susCombo, child, child.getChildCount());
		treeModel.insertNodeInto(recommendedTestCases, child,
				child.getChildCount());
		treeModel.insertNodeInto(susComponents, child, child.getChildCount());
		tree.setSelectionPath(new TreePath(recommendedTestCases));

	}

	protected void updateGUI(IterationResult itr,int count, SUT localSUT, int curCmbLen) {
		//System.out.println("Current Iteration: "+count+"\n"+"Size of list:"+localSUT.getIterationObject().size());
		if(count == 1)
		{
		updateGUI_Iteration1(itr,count,localSUT,curCmbLen);
		}
		else if(count == 2)
		{
		updateGUI_Iteration2(itr,count,localSUT,curCmbLen);
		}
		else if(count == 3)
		{
		updateGUI_Iteration3(itr,count,localSUT,curCmbLen);
		}
		else if(count == 4)
		{
		updateGUI_Iteration4(itr,count,localSUT,curCmbLen);
		}
		else if(count == 5)
		{
		updateGUI_Iteration5(itr,count,localSUT,curCmbLen);
		}
		else if(count == 6)
		{
		updateGUI_Iteration6(itr,count,localSUT,curCmbLen);
		}

	}

	private void updateGUI_Iteration6(IterationResult itr, int count, SUT localSUT,int curCmbLen) {


		// Table for new recommended test set
		System.out.println("Count in iteration 6:"+count);
		rtsTable6 = new DefaultTableModel();
		rts_JTable6 = new JTable(rtsTable6);

		// table for suspicious combinations
		nscTable6 = new DefaultTableModel();
		nsc_JTable6 = new JTable(nscTable6);

		// Table for Suspicious Components
		susComponentTable6 = new DefaultTableModel();
		susComponent_JTable6 = new JTable(susComponentTable6);

		JScrollPane ntc_ScrollPane = new JScrollPane(rts_JTable6);
		ntc_ScrollPane
				.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		// ntc_ScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

		JScrollPane nsc_ScrollPane = new JScrollPane(nsc_JTable6);
		// nsc_ScrollPane
		// .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		JScrollPane susCombo_ScrollPane = new JScrollPane(susComponent_JTable6);
		// susCombo_ScrollPane
		// .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);

		// Panel for New Test Case
		rts_Panel6 = new JPanel();
		rts_Panel6.setLayout(new BorderLayout());
		rts_Panel6.add(ntc_ScrollPane);

		// Panel for new suscipisious combinations

		nsc_Panel6 = new JPanel();
		nsc_Panel6.setLayout(new BorderLayout());
		nsc_Panel6.add(nsc_ScrollPane, BorderLayout.CENTER);
		//nsc_Panel6.add(susCombFilter, BorderLayout.NORTH);

		// Panel for New Test Case
		susComponent_Panel6 = new JPanel();
		susComponent_Panel6.setLayout(new BorderLayout());
		susComponent_Panel6.add(susCombo_ScrollPane);

		loadNSC(itr,nscTable6,nsc_JTable6,localSUT,curCmbLen);
		loadNTC(itr,rtsTable6,rts_JTable6,localSUT);
		loadSusCombo(itr,susComponentTable6,susComponent_JTable6,localSUT);

	}

	private void updateGUI_Iteration5(IterationResult itr, int count, SUT localSUT,int curCmbLen) {

		// Table for new recommended test set
		System.out.println("Count in iteration 5:"+count);
		rtsTable5 = new DefaultTableModel();
		rts_JTable5 = new JTable(rtsTable5);

		// table for suspicious combinations
		nscTable5 = new DefaultTableModel();
		nsc_JTable5 = new JTable(nscTable5);

		// Table for Suspicious Components
		susComponentTable5 = new DefaultTableModel();
		susComponent_JTable5 = new JTable(susComponentTable5);

		JScrollPane ntc_ScrollPane = new JScrollPane(rts_JTable5);
		ntc_ScrollPane
				.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		// ntc_ScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

		JScrollPane nsc_ScrollPane = new JScrollPane(nsc_JTable5);
		// nsc_ScrollPane
		// .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		JScrollPane susCombo_ScrollPane = new JScrollPane(susComponent_JTable5);
		// susCombo_ScrollPane
		// .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);

		// Panel for New Test Case
		rts_Panel5 = new JPanel();
		rts_Panel5.setLayout(new BorderLayout());
		rts_Panel5.add(ntc_ScrollPane);

		// Panel for new suscipisious combinations

		nsc_Panel5 = new JPanel();
		nsc_Panel5.setLayout(new BorderLayout());
		nsc_Panel5.add(nsc_ScrollPane, BorderLayout.CENTER);
		//nsc_Panel5.add(susCombFilter, BorderLayout.NORTH);

		// Panel for New Test Case
		susComponent_Panel5 = new JPanel();
		susComponent_Panel5.setLayout(new BorderLayout());
		susComponent_Panel5.add(susCombo_ScrollPane);

		loadNSC(itr,nscTable5,nsc_JTable5,localSUT,curCmbLen);
		loadNTC(itr,rtsTable5,rts_JTable5,localSUT);
		loadSusCombo(itr,susComponentTable5,susComponent_JTable5,localSUT);

	}

	private void updateGUI_Iteration4(IterationResult itr, int count, SUT localSUT,int curCmbLen) {


		// Table for new recommended test set
		System.out.println("checkSUTStatusCount in iteration 4:"+count);
		rtsTable4 = new DefaultTableModel();
		rts_JTable4 = new JTable(rtsTable4);

		// table for suspicious combinations
		nscTable4 = new DefaultTableModel();
		nsc_JTable4 = new JTable(nscTable4);

		// Table for Suspicious Components
		susComponentTable4 = new DefaultTableModel();
		susComponent_JTable4 = new JTable(susComponentTable4);

		JScrollPane ntc_ScrollPane = new JScrollPane(rts_JTable4);
		ntc_ScrollPane
				.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		// ntc_ScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

		JScrollPane nsc_ScrollPane = new JScrollPane(nsc_JTable4);
		// nsc_ScrollPane
		// .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		JScrollPane susCombo_ScrollPane = new JScrollPane(susComponent_JTable4);
		// susCombo_ScrollPane
		// .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);

		// Panel for New Test Case
		rts_Panel4 = new JPanel();
		rts_Panel4.setLayout(new BorderLayout());
		rts_Panel4.add(ntc_ScrollPane);

		// Panel for new suscipisious combinations

		nsc_Panel4 = new JPanel();
		nsc_Panel4.setLayout(new BorderLayout());
		nsc_Panel4.add(nsc_ScrollPane, BorderLayout.CENTER);
		//nsc_Panel4.add(susCombFilter, BorderLayout.NORTH);

		// Panel for New Test Case
		susComponent_Panel4 = new JPanel();
		susComponent_Panel4.setLayout(new BorderLayout());
		susComponent_Panel4.add(susCombo_ScrollPane);

		loadNSC(itr,nscTable4,nsc_JTable4,localSUT,curCmbLen);
		loadNTC(itr,rtsTable4,rts_JTable4,localSUT);
		loadSusCombo(itr,susComponentTable4,susComponent_JTable4,localSUT);

	}

	private void updateGUI_Iteration3(IterationResult itr, int count, SUT localSUT,int curCmbLen) {


		// Table for new recommended test set
		System.out.println("Count in iteration 3:"+count);
		rtsTable3 = new DefaultTableModel();
		rts_JTable3 = new JTable(rtsTable3);

		// table for suspicious combinations
		nscTable3 = new DefaultTableModel();
		nsc_JTable3 = new JTable(nscTable3);

		// Table for Suspicious Components
		susComponentTable3 = new DefaultTableModel();
		susComponent_JTable3 = new JTable(susComponentTable3);

		JScrollPane ntc_ScrollPane = new JScrollPane(rts_JTable3);
		ntc_ScrollPane
				.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		// ntc_ScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

		JScrollPane nsc_ScrollPane = new JScrollPane(nsc_JTable3);
		// nsc_ScrollPane
		// .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		JScrollPane susCombo_ScrollPane = new JScrollPane(susComponent_JTable3);
		// susCombo_ScrollPane
		// .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);

		// Panel for New Test Case
		rts_Panel3 = new JPanel();
		rts_Panel3.setLayout(new BorderLayout());
		rts_Panel3.add(ntc_ScrollPane);

		// Panel for new suscipisious combinations

		nsc_Panel3 = new JPanel();
		nsc_Panel3.setLayout(new BorderLayout());
		nsc_Panel3.add(nsc_ScrollPane, BorderLayout.CENTER);
		//nsc_Panel3.add(susCombFilter, BorderLayout.NORTH);

		// Panel for New Test Case
		susComponent_Panel3 = new JPanel();
		susComponent_Panel3.setLayout(new BorderLayout());
		susComponent_Panel3.add(susCombo_ScrollPane);

		loadNSC(itr,nscTable3,nsc_JTable3,localSUT,curCmbLen);
		loadNTC(itr,rtsTable3,rts_JTable3,localSUT);
		loadSusCombo(itr,susComponentTable3,susComponent_JTable3,localSUT);

	}

	private void updateGUI_Iteration2(IterationResult itr, int count, SUT localSUT, int curCmbLen) {

		// Table for new recommended test set
		System.out.println("Count in iteration 2:"+count);
		rtsTable2 = new DefaultTableModel();
		rts_JTable2 = new JTable(rtsTable2);

		// table for suspicious combinations
		nscTable2 = new DefaultTableModel();
		nsc_JTable2 = new JTable(nscTable2);

		// Table for Suspicious Components
		susComponentTable2 = new DefaultTableModel();
		susComponent_JTable2 = new JTable(susComponentTable2);

		JScrollPane ntc_ScrollPane = new JScrollPane(rts_JTable2);
		ntc_ScrollPane
				.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		// ntc_ScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

		JScrollPane nsc_ScrollPane = new JScrollPane(nsc_JTable2);
		// nsc_ScrollPane
		// .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		JScrollPane susCombo_ScrollPane = new JScrollPane(susComponent_JTable2);
		// susCombo_ScrollPane
		// .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);

		// Panel for New Test Case
		rts_Panel2 = new JPanel();
		rts_Panel2.setLayout(new BorderLayout());
		rts_Panel2.add(ntc_ScrollPane);

		// Panel for new suscipisious combinations

		nsc_Panel2 = new JPanel();
		nsc_Panel2.setLayout(new BorderLayout());
		nsc_Panel2.add(nsc_ScrollPane, BorderLayout.CENTER);
		//nsc_Panel2.add(susCombFilter, BorderLayout.NORTH);

		// Panel for New Test Case
		susComponent_Panel2 = new JPanel();
		susComponent_Panel2.setLayout(new BorderLayout());
		susComponent_Panel2.add(susCombo_ScrollPane);

		loadNSC(itr,nscTable2,nsc_JTable2,localSUT,curCmbLen);
		loadNTC(itr,rtsTable2,rts_JTable2,localSUT);
		loadSusCombo(itr,susComponentTable2,susComponent_JTable2,localSUT);



	}

	private void updateGUI_Iteration1(IterationResult itr, int count, SUT localSUT, int curCmbLen) {
		// Table for new recommended test set
		System.out.println("Count:"+count);
		rtsTable = new DefaultTableModel();
		ntc_JTable = new JTable(rtsTable);

		// table for suspicious combinations
		susTable = new DefaultTableModel();
		nsc_JTable = new JTable(susTable);

		// Table for Suspicious Components
		susComponentTable = new DefaultTableModel();
		susComponent_JTable = new JTable(susComponentTable);

		JScrollPane ntc_ScrollPane = new JScrollPane(ntc_JTable);
		ntc_ScrollPane
				.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		// ntc_ScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

		JScrollPane nsc_ScrollPane = new JScrollPane(nsc_JTable);
		// nsc_ScrollPane
		// .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		JScrollPane susCombo_ScrollPane = new JScrollPane(susComponent_JTable);
		// susCombo_ScrollPane
		// .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);

		// Panel for New Test Case
		ntc_Panel = new JPanel();
		ntc_Panel.setLayout(new BorderLayout());
		ntc_Panel.add(ntc_ScrollPane);

		// Panel for new suscipisious combinations

		nsc_Panel = new JPanel();
		nsc_Panel.setLayout(new BorderLayout());
		nsc_Panel.add(nsc_ScrollPane, BorderLayout.CENTER);
	//	nsc_Panel.add(susCombFilter, BorderLayout.NORTH);

		// Panel for New Test Case
		susCombo_Panel = new JPanel();
		susCombo_Panel.setLayout(new BorderLayout());
		susCombo_Panel.add(susCombo_ScrollPane);

		loadNSC(itr,susTable,nsc_JTable,localSUT,curCmbLen);
		loadNTC(itr,rtsTable,ntc_JTable,localSUT);
		loadSusCombo(itr,susComponentTable,susComponent_JTable,localSUT);

	}

	@SuppressWarnings("static-access")
	protected void initialLoad() {
		System.out.println("Input file location:" + inputTestFile);
		cflEngineObject.processLoad(inputTestFile);
		SUT sutLocalCopy_InitialLoad = cflEngineObject.getSut();
		int curCmbLen = cflEngineObject.curCmbLen;
		itrCount++;
		System.out.println("In GUI:::::Iteration Count:  "+itrCount+"testing arraylist size: "+(sutLocalCopy_InitialLoad.getIterationObject().size()));
		updateGUI(sutLocalCopy_InitialLoad.getIterationObject().get(itrCount-1),itrCount,sutLocalCopy_InitialLoad,curCmbLen);
		initialBuildBtn.setEnabled(false);
		checkSUTStatus(sutLocalCopy_InitialLoad);

	} // end of method

	protected void checkSUTStatus(SUT sut) {
		SUTState status = sut.getStatus();

		//System.out.println("*****status testing:******"+status);

		if(status == SUTState.continuing)
		{
			iterativeBuildBtn.setEnabled(true);
			JOptionPane.showMessageDialog(frame, "To increase the confidence of suspicious combos, we recommended you to execute new test cases.\n Update the result section in the receommended test set and click on Continue Iteration button on the tool bar");

		}
		else if(status == SUTState.notFound)
		{
			iterativeBuildBtn.setEnabled(false);
			JOptionPane.showMessageDialog(frame, "All tests fails and all combos are failure-inducing","Iane Warning",JOptionPane.ERROR_MESSAGE);
		}
		else if(status == SUTState.noImprovement)
		{
			iterativeBuildBtn.setEnabled(false);
			JOptionPane.showMessageDialog(frame, "Adding tests makes no improvement","Inane error",JOptionPane.ERROR_MESSAGE);
		}
		else if(status == SUTState.InducingTest)
		{
			iterativeBuildBtn.setEnabled(false);
			JOptionPane.showMessageDialog(frame, "No inducing combination, failed tests are inducing","Inane error",JOptionPane.ERROR_MESSAGE);
		}
		else
		{
			iterativeBuildBtn.setEnabled(false);
			JOptionPane.showMessageDialog(frame,"cannot proceed further");
		}
	}

	protected void susComboHeader(DefaultTableModel susComponentTable) {
		String[] susComboHeader = (new SusComboColumnHeader().getColumnName());

		for (int columnPos = 0; columnPos < susComboHeader.length; columnPos++) {
			susComponentTable.addColumn(susComboHeader[columnPos]);
		}
	}

	protected void susComboRow(IterationResult itr,DefaultTableModel susComponentTable, SUT localSUT) {

		ArrayList<String> suspiciousComponents = (new LoadSuspiciousComponents(
				itr, localSUT).getSuspiciousComponents());
		Pattern values = Pattern.compile(",");
		for (int a = 0; a < suspiciousComponents.size(); a++) {
			String[] tokens = values.split(suspiciousComponents.get(a));
			susComponentTable.addRow(tokens);
		}
		

	}

	public void loadNTC(IterationResult itr, DefaultTableModel rtsTable, JTable rtsJTable, SUT localSUT) {
 
		loadRTSHeader(rtsTable,localSUT);
		loadRecommendedTestSet(itr,rtsTable,rtsJTable,localSUT);
		new TableDecorator(ntc_JTable).updateTableUI();
		rtsJTable.getTableHeader().setReorderingAllowed(false);
	
	}

	public void loadNSC(IterationResult itr,DefaultTableModel susTable,JTable nscJTable, SUT localSUT, int curCmbLen) {
		susCombinationsColumnName(susTable, nscJTable,localSUT);
		susCombinationRowData(itr,susTable, nscJTable,localSUT,curCmbLen);
		new TableDecorator(nsc_JTable).updateTableUI();
		nscJTable.getTableHeader().setReorderingAllowed(false);
		nscJTable.setEnabled(false); // user can not edit the table
	}

	public void susCombinationsColumnName(DefaultTableModel susTable,JTable nscJTable,SUT localSUT) {
		ContextClass obj = new ContextClass(localSUT.getStrength());
		String[] columnHeader = obj.getColumnHeader();
		susComboSize = columnHeader.length;
		susTable.setColumnCount(0);
		susTable.setRowCount(0);

		for (int columnPos = 0; columnPos < columnHeader.length; columnPos++) {
			susTable.addColumn(columnHeader[columnPos]);
		}
		resizeColumnWidth(nsc_JTable);

	}

	public void susCombinationRowData(IterationResult itr,DefaultTableModel susTable,JTable nscJTable,SUT localSUT, int curCmbLen) {
		// new logic
		for (int row = 0; row < suspiciousCombination.size(); row++) {
			// String rowString = suspiciousCombination.get(row);
			// rowString = rowString.replaceAll("\\s+","(");
			// rowString = rowString.replaceAll("\\s+",")");
			// String[] items = rowString.split(",");
			// susTable.addRow(items);
		}

		LoadSuspiciousCombination obj = new LoadSuspiciousCombination(itr,localSUT,curCmbLen);
		ArrayList<String> susCombination = obj.getSuspiciousCombinations();
		int numOfParameters = obj.getParameterCount();

		//Column header information
		ContextClass contextObj = new ContextClass(numOfParameters);
		String[] columnHeader = contextObj.getColumnHeader();
		susComboSize = columnHeader.length;
		susTable.setColumnCount(0);
		susTable.setRowCount(0);

		for (int columnPos = 0; columnPos < columnHeader.length; columnPos++) {
			susTable.addColumn(columnHeader[columnPos]);
		}
		resizeColumnWidth(nsc_JTable);
		nsc_JTable.getTableHeader().setReorderingAllowed(false); // not allow the user to re-align the column

		// Row information
		Pattern values = Pattern.compile(",");

		for (int a = 0; a < susCombination.size(); a++) {
			String[] tokens = values.split(susCombination.get(a));
			susTable.addRow(tokens);
		}
		// Applying filter
		 susCombFilter.setTable(nscJTable);
		 susCombFilter.setPosition(Position.INLINE);
		 susCombFilter.setAutoChoices(AutoChoices.ENABLED);
		 susCombFilter.setBackground(Color.LIGHT_GRAY);
		 susCombFilter.setForeground(Color.BLACK);
		}

	public void loadRecommendedTestSet(IterationResult itr,DefaultTableModel rtsTable,JTable ntc_JTable, SUT localSUT) {
		// new logic
		LoadRecommendedTestSet obj = new LoadRecommendedTestSet(itr, localSUT);
		ArrayList<String> tempList = obj.getRecommendedTestSet();

		for (int row = 0; row < tempList.size(); row++) {
			String rowString = tempList.get(row);
			rowString = rowString.replaceAll("\\s+", "");
			String[] items = rowString.split(",");
			rtsTable.addRow(items);
		}

		// Introducing the result column
		rtsTable.addColumn("Results");
		int numberOfColumns = rtsTable.getColumnCount();
		setUpResultColumn(ntc_JTable,ntc_JTable.getColumnModel().getColumn(numberOfColumns - 1));
		
		
		}
	
	private void setUpResultColumn(JTable ntc_Table, TableColumn column) {
		// This method is used to introduce drop-down list options for RESULTS
		JComboBox comboBox = new JComboBox();
		comboBox.addItem("Pass");
		comboBox.addItem("Fail");
		column.setCellEditor(new DefaultCellEditor(comboBox));

		// Set up tool tips for the sport cells.
		DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
		renderer.setToolTipText("Click for combo box");
		column.setCellRenderer(renderer);
	}

	public void loadRTSHeader(DefaultTableModel rtsTable, SUT localSUT) {
		ArrayList<String> columnName = new ArrayList<String>();
		columnName.add("Test #");
		for (Parameter prm : localSUT.getParameters()) {
			columnName.add(prm.getName());

		}

		for (int i = 0; i < columnName.size(); i++) {
			rtsTable.addColumn(columnName.get(i));
		}
		} // end of logic - loadColumnHeader();

	public void resizeColumnWidth(JTable table) {
		final TableColumnModel columnModel = table.getColumnModel();
		for (int column = 0; column < table.getColumnCount(); column++) {

			int width = 200; // Min width
			for (int row = 0; row < table.getRowCount(); row++) {
				TableCellRenderer renderer = table.getCellRenderer(row, column);
				Component comp = table.prepareRenderer(renderer, row, column);
				width = Math.max(comp.getPreferredSize().width, width);
			}
			columnModel.getColumn(column).setPreferredWidth(width);
		}
	}

}